package org.familysearch.fsapi.gwt.server.api;

import java.util.ArrayList;

import org.apache.log4j.Logger;
import org.familysearch.fsapi.gwt.common.client.entities.Temple;
import org.familysearch.fsapi.gwt.server.bo.BOException;
import org.familysearch.fsapi.gwt.server.bo.TempleBO;

public class TempleAPI extends API {

	private TempleBO bo = new TempleBO();
	private Logger log;
	
	public TempleAPI()
	{
		super();
		log = Logger.getLogger(this.getClass().getName());
	}
	
	public Temple getTemple(Temple temple) throws APIException
	{
		Temple fetched = null;
		try
		{
			fetched = bo.getTemple(temple);
		}
		catch(BOException e)
		{
			log.error(e.toString());
			APIException ex = new APIException("API-0001", "Could not retrieve temple.");
			throw ex;
		}
		return fetched;
		
	}
	
	public ArrayList<Temple> getTemples() throws APIException
	{
		ArrayList<Temple> temples = null;
		try
		{
			temples = bo.getTemples();
		}
		catch(BOException e)
		{
			APIException ex = new APIException();
			throw ex;
		}
		return temples;
	}
	
	public ArrayList<Temple> getTemples(Temple temple) throws APIException
	{
		ArrayList<Temple> temples = null;
		try
		{
			temples = bo.getTemples(temple);
		}
		catch(BOException e)
		{
			APIException ex = new APIException();
			throw ex;
		}
		return temples;
	}	
	
}
